<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
 * @author Anh Nguyen <duyanhnguyen@vccorp.vn>
 * @copyright 2012
 */

class Dashboard extends MX_Controller
{

    function __construct()
    {
        parent::__construct();
        $this->load->library('Admin_Layout');
    }
    
    public function index()
    {
        $this->mycommon->authAdmin();
        $data = array();
        $this->load->model('sim/sim_model');
        $data['current'] = 0;
        $start = strtotime('-1 month');
        $end = time();
        $data['sim'] = $this->sim_model->getAllSimSale(0, $start, $end);
        $this->admin_layout->render('dashboard/dashboard_view', $data);
    }
    
    public function load()
    {
        $this->mycommon->authAdmin();
        $data = array();
        $type = $this->input->post('type');
        $startDate = $this->input->post('start');
        $endDate = $this->input->post('end');
        $type = ($type == 'new') ? 0 : 3;
        $startDate = preg_replace('/(\d+)\/(\d+)\/(\d+)/', '$1-$2-$3', $startDate);
        $endDate = preg_replace('/(\d+)\/(\d+)\/(\d+)/', '$1-$2-$3', $endDate);
        $startDate = strtotime($startDate);
        $endDate = strtotime($endDate);
        $this->load->model('sim/sim_model');
        $data['sim'] = $this->sim_model->getAllSimSale(0, $startDate, $endDate);
        echo $this->load->view('dashboard/load_view', $data, TRUE);
    }

}

?>
